﻿using BoatNGoat.Logic.Map;

namespace BoatNGoat.Logic
{
    class MapMovementConstraint : IMovementConstraint
    {
        private readonly IMap _map;

        public MapMovementConstraint(IMap map)
        {
            _map = map;
        }

        public bool AllowedOnWater { get; set; }
        public bool AllowedOnLand { get; set; }
        public bool AllowedOnMountain { get; set; }

        public bool CanMoveTo(MapBox2 newPlace)
        {
            MapCollisionData data = _map.Collide(newPlace);

            if (data.Water && !AllowedOnWater) return false;
            if (data.Land && !AllowedOnLand) return false;
            if (data.Blocked && !AllowedOnMountain) return false;

            return true;
        }
    }
}